//
//  UIBarButton+Extension.swift
//  SinaWeibo
//
//  Created by 周小伟 on 16/8/24.
//  Copyright © 2016年 周小伟. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
    convenience init(imageName:String,target:AnyObject?,actionName:String?){
        let btn = UIButton(type: .Custom)
        btn.setImage(UIImage(named: imageName), forState: .Normal)
        btn.setImage(UIImage(named: imageName + "_highlighted"), forState: .Highlighted)
        if let action = actionName,targetObj = target{
            btn.addTarget(targetObj, action: Selector(action), forControlEvents: .TouchUpInside)
        }
        btn.sizeToFit()
        self.init(customView:btn)
    }
}
